/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package cp2004;
import java.io.*;
/**
 *
 * @author NC10
 */
public class MainUI {
    private static String OPTION_1 ="1.Show List of Products";
    private static String OPTION_2 ="2.Show List of Inventory items";
    private static String OPTION_3 ="3.Show List of Inventory items for Product";
    private static final int CANCEL=0;
    private static final int OPTION_1_ID = 1;
    private static final int OPTION_2_ID = 2;
    private static final int OPTION_3_ID = 3;
            public void run(){

                while(true){
                System.out.println(OPTION_1);
                System.out.println(OPTION_2);
                System.out.println(OPTION_3);
                     int opt = getUserInput();
   switch(opt){
            case OPTION_1_ID:
                ProductArr arr = new ProductArr();
                System.out.println("Product List:\n" + arr);
                break;
            case OPTION_2_ID:
                 itemArr arr2 = new itemArr();
                System.out.println("Inventory List:\n" + arr2);
                break;
            case OPTION_3_ID:
                ProductArr arr3 = new ProductArr();
                System.out.println("Inventory List:\n" + arr3);
                 System.out.println("which one?");
                    int ProdId = getUserInput();       
                    Product p=arr3.get(ProdId - 1);
                System.out.println("For this product you need:\n" + p.getArr());
                break;
            default:
                return;
     }

                }
                }

            private int getUserInput(){
             try {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String str = "";
        while (str != null) {
            System.out.print("> Enter 1,2,3:");
            str = in.readLine();
            return Integer.parseInt(str);
            //process(str);
        }
    } catch (IOException e) {
        return CANCEL;
    }catch(NumberFormatException e){
    return CANCEL;
    }
            return 0;

            }

}
